package com.waitingresult.designpattern.demo.entity;

import com.alibaba.fastjson2.JSON;

/**
 * @Author: WangShuai
 * @CreateTime: 2022-12-15  21:24
 * @Description:
 * @Version: 1.0
 */
public class DemoRequest<T extends BaseEntity> {

    private String name;
    private String detailString;

    private T detail;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public T getDetail() {
        return detail;
    }

    public void setDetail(T detail) {
        this.detailString = JSON.toJSONString(detail);
    }

    public void setDetailString(String detailString) {
        this.detailString = detailString;
        if ("11".equals(name)) {
            this.detail = (T)JSON.parseObject(detailString, DetailOne.class);
        }else if ("22".equals(name)){
            this.detail = (T)JSON.parseObject(detailString, DetailTwo.class);

        }
    }
}
